<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>商户管理</title>

    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div id="merchant">
<div class="panel panel-default">
    <div class="panel-heading">商品信息列表</div>
    <div class="panel-body">

        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">新增商户信息</h4>
                    </div>
                    <div class="modal-body">

                        <form>
                            <div class="form-group">
                                <label for="merchantName">商户名称</label>
                                <input type="text" class="form-control" id="merchantName" placeholder="Email">
                            </div>
                            <div class="form-group">
                                <label for="qq">QQ号码</label>
                                <input type="text" class="form-control" id="qq" placeholder="Password">
                            </div>

                            <div class="form-group">
                                <label for="wxh">微信号码</label>
                                <input type="text" class="form-control" id="wxh" placeholder="Password">
                            </div>

                            <div class="form-group">
                                <label for="lxdh">联系电话</label>
                                <input type="text" class="form-control" id="lxdh" placeholder="Password">
                            </div>

                            <div class="form-group">
                                <label for="dlzh">登录账号</label>
                                <input type="text" class="form-control" id="dlzh" placeholder="Password">
                            </div>

                            <div class="form-group">
                                <label for="dlmm">登录密码</label>
                                <input type="password" class="form-control" id="dlmm" placeholder="Password">
                            </div>

                            <div class="form-group">
                                <label for="shdj">商户等级</label>
                                <select id="shdj">
                                    <option value="-1">请选择...</option>
                                    <option value="0">非认证商户</option>
                                    <option value="1">认证商户V1</option>
                                    <option value="2">认证商户V2</option>
                                </select>
                            </div>

                            <div class="form-group">
                                <label for="sfyx">是否有效</label>
                                <div id="sfyx">
                                    <input type="radio" name="state" value="1">有效 <input type="radio"  name="state" value="0">无效
                                </div>
                            </div>


                        </form>
                    </div>
                    <div class="modal-footer">

                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary" onclick="save()">Save changes</button>
                    </div>
                </div>
            </div>
        </div>

       <!-- <button type="button" class="btn btn-primary" onclick="javascript:$('#exampleModal').modal('show');" >Open modal for @mdo</button>

        <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="exampleModalLabel">New message</h4>
                    </div>
                    <div class="modal-body">
                        <form>
                            <div class="form-group">
                                <label for="recipient-name" class="control-label">Recipient:</label>
                                <input type="text" class="form-control" id="recipient-name">
                            </div>
                            <div class="form-group">
                                <label for="message-text" class="control-label">Message:</label>
                                <textarea class="form-control" id="message-text"></textarea>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary">Send message</button>
                    </div>
                </div>
            </div>
        </div>-->


        <!--商户列表-->

        <table class="table table-bordered">
            <thead>
            <tr>
                <th>序号</th>
                <th>图片</th>
                <th>商品名称</th>

                <th>加入时间</th>
                <th>推荐</th>
                <th>置顶</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>

            <tr th:each="merchant : ${wxbGoods}">
                <th scope="row" th:text="${merchant.good_Id}">2</th>
                <th>
                    <img style="height: 50px;width: 100px" th:src="@{${merchant.good_Pic}}">
                </th>
                <td th:text="${merchant.good_Name}">Jacob</td>
                <td th:text="${merchant.create_Time}">@fat</td>
                <td th:text="${merchant.toped}">@fat</td>
                <td th:text="${merchant.recomed}">@fat</td>
                <td th:text="${merchant.state}">@fat</td>
                <td >
                    <a>编辑</a>
                    <a>删除</a>
                </td>
            </tr>

            </tbody>
        </table>
    </div>
</div>

</div>

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<!--<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>-->
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>

<script>
    function save() {
         var merchantName = $("#merchantName").val();
         var qq = $("#qq").val();
        var wxh = $("#wxh").val();
        var phone = $("#lxdh").val();
        var username = $("#dlzh").val();
        var password = $("#dlmm").val();
        var level = $("#shdj").val();
        var state = $("input[name='state']:checked").val();

        console.log(merchantName+"/"+state+"/"+qq+"/"+wxh+"/"+phone+"/"+username+"/"+password+"/"+level);
        // private String customerId;
        // private String customerName;
        // private String qq;
        // private String wxh;
        // private String phone;
        // private java.sql.Timestamp createtime;
        // private String loginName;
        // private String loginPwd;
        // private long state;
        // private long level;
        // private double accBalance;
        // private java.sql.Timestamp updateTime;
        // private String website;
        $.post("merchant/save",
            {customerName:merchantName,qq:qq,wxh:wxh,phone:phone,loginName:username,loginPwd:password,state:state,level:level},
            function (data) {
                if (data.code==1) {
                    console.log("新增成功");
                    $('#myModal').modal("hide");
                    $("#merchant").load("merchant/list");

                } else {
                    console.log("新增失败");
                }
            });

    }
</script>
</body>
</html>